3eb781fdpgi83RpUvQWVccWjsDJK7w tools/control/src/org/xenoserver/control/StringPattern.java
3ec41f7dUPpYTwYL5QVpRBv6PLKPrg tools/control/src/org/xenoserver/control/XML.java
3ec41f7d7Try-2zmfnpaALwJjY0GCA tools/control/src/org/xenoserver/control/XMLHelper.java
-3ec41f7csVaMDEEUMZBotpSftCy0rg tools/control/src/uk/ac/cam/cl/xeno/xenctl/Extent.java
-3ec41f7cO5uUI4qZmJ29jsammoZP4Q tools/control/src/uk/ac/cam/cl/xeno/xenctl/Library.java
3ec41f7civcv4mQiYK0DeX9Zvsxhrw tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig
-3ec41f7dOVcHj4xU3BFut_einNzj6A tools/control/src/uk/ac/cam/cl/xeno/xenctl/Mode.java
3ec41f7d3-xTeoVJBJqWqxVfU-ANoQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java
-3ec41f7dnnLe-6h-XWIvQVoP9oZu_A tools/control/src/uk/ac/cam/cl/xeno/xenctl/Partition.java
-3ec41f7dD8h6MGxKTPtKzXPdGJS7bw tools/control/src/uk/ac/cam/cl/xeno/xenctl/PartitionManager.java
3ec41f7dOVZgjP4sQS6vjuBnExdlMQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/RootBean.java
3ec41f7dvPdszb0frNEkMnEdJUBVjA tools/control/src/uk/ac/cam/cl/xeno/xenctl/SystemConfigurationBean.java
3ec41f7dlW5Buk3MO18HHtBax1Jz9g tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualBlockDevice.java
3ec41f7dP3VglJUTuP45rwvSAoW_pg tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDisk.java
3ec41f7d8_ZsS9JjYQq861OFAZS9GA tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDiskManager.java
-3ec41f7dSJieScU3uvPMGXk-8NgHvA tools/control/src/uk/ac/cam/cl/xeno/xenctl/XML.java
-3ec41f7dGO96BS8-6FWGDjCxjncOGg tools/control/src/uk/ac/cam/cl/xeno/xenctl/XMLHelper.java
3ec41f7dO6IuKGGLG4VRUhMDmkTn5g tools/control/web/WEB-INF/web.xml
3ec41f7dRAPXBA0jQUd1k6MB3xVidg tools/control/web/img/cambridge.gif
3ec41f7dvxVe1Vb3kVOLZcN5Jra2tQ tools/control/web/img/help.gif
+++ /dev/null
-/*
- * Extent.java
- * 03.03.26 aho creation
- */
-
-package uk.ac.cam.cl.xeno.xenctl;
-
-public class
-Extent
-{
- int disk;
- long offset; /* offset into disk */
- long size; /* size of this extent in 512 byte sectors */
-
- public int
- getDisk()
- {
- return disk;
- }
-
- public long
- getOffset()
- {
- return offset;
- }
-
- public long
- getSize()
- {
- return size;
- }
-}
+++ /dev/null
-/*
- * Library.java
- * 03.03.28 aho creation
- */
-
-package uk.ac.cam.cl.xeno.xenctl;
-
-public class
-Library
-{
- /*
- * convert a number to a fixed width string
- */
- static String
- format (long input, int width, int prefix)
- {
- String sss = Long.toString(input);
- String space = " ";
-
- if (width < sss.length())
- {
- width = sss.length();
- }
-
- if (prefix == 0)
- {
- return space.substring(0, width - sss.length()) + sss;
- }
- else
- {
- return sss + space.substring(0, width - sss.length());
- }
- }
-
- /*
- * convert a string to a fixed width string
- */
- static String
- format (String input, int width, int prefix)
- {
- String space = " ";
-
- if (width < input.length())
- {
- width = input.length();
- }
-
- if (prefix == 0)
- {
- return space.substring(0, width - input.length()) + input;
- }
- else
- {
- return input + space.substring(0, width - input.length());
- }
- }
-
- /*
- * convert a number (string format) into
- * the corresponding integer value.
- */
- static long
- parse_size(String size)
- {
- String substring = size;
- int suffix = 1;
- long value = 0;
-
- if (size == null)
- {
- return 0;
- }
-
- if ((substring = check(size, 'm')) != null)
- {
- suffix = 1024 * 1024;
- }
- else if ((substring = check(size, 'M')) != null)
- {
- suffix = 1024 * 1024;
- }
- else if ((substring = check(size, 'k')) != null)
- {
- suffix = 1024;
- }
- else if ((substring = check(size, 'K')) != null)
- {
- suffix = 1024;
- }
- else if ((substring = check(size, 'g')) != null)
- {
- suffix = 1024 * 1024 * 1024;
- }
- else if ((substring = check(size, 'G')) != null)
- {
- suffix = 1024 * 1024 * 1024;
- }
- else
- {
- substring = size;
- }
-
- try
- {
- value = Long.decode(substring).longValue() * suffix;
- }
- catch (NumberFormatException e)
- {
- value = 0;
- }
-
- return value;
- }
-
- static String
- check(String size, char suffix)
- {
- int index = size.indexOf(suffix);
-
- if (index != -1)
- {
- return size.substring(0, index);
- }
- else
- {
- return null;
- }
- }
-}
+++ /dev/null
-/*
- * Mode.java
- * 03.03.27 aho creation
- *
- * until we have jdk1.5, we're left with this mess...
- */
-
-package uk.ac.cam.cl.xeno.xenctl;
-
-public class
-Mode
-{
- private final String name;
-
- private Mode(String name) { this.name = name; }
-
- public String toString() { return name; }
-
- public static final Mode READ_ONLY = new Mode("ro");
- public static final Mode READ_WRITE = new Mode("rw");
-}
-
+++ /dev/null
-/*
- * Partition.java
- * 03.03.26 aho creation
- */
-
-package uk.ac.cam.cl.xeno.xenctl;
-
-import java.io.*;
-
-public class
-Partition
-{
- int major;
- int minor;
- long blocks;
- long start_sect;
- long nr_sects;
- String name;
- boolean xeno;
-
- boolean
- identical (Partition p)
- {
- return (major == p.major &&
- minor == p.minor &&
- blocks == p.blocks &&
- start_sect == p.start_sect &&
- nr_sects == p.nr_sects &&
- name.equals(p.name));
- }
-
- Partition
- duplicate ()
- {
- Partition p = new Partition();
-
- p.major = major;
- p.minor = minor;
- p.blocks = blocks;
- p.start_sect = start_sect;
- p.nr_sects = nr_sects;
- p.name = name;
- p.xeno = xeno;
-
- return p;
- }
-
- String
- dump (boolean title)
- {
- if (title)
- {
- return ("maj:min " +
- " blocks " +
- "start sect " +
- " num sects " +
- "name");
- }
- else
- {
- return (Library.format(major,3,0) + ":" +
- Library.format(minor,3,1) + " " +
- Library.format(blocks,10,0) + " " +
- Library.format(start_sect,10,0) + " " +
- Library.format(nr_sects,10,0) + " " +
- Library.format(name,7,1));
- }
- }
-
- void
- dump_xml(PrintWriter out)
- {
- out.println (" <partition>\n" +
- " <major>" + major + "</major>\n" +
- " <minor>" + minor + "</minor>\n" +
- " <blocks>" + blocks + "</blocks>\n" +
- " <start_sect>" + start_sect + "</start_sect>\n" +
- " <nr_sects>" + nr_sects + "</nr_sects>\n" +
- " <name>" + name + "</name>\n" +
- " </partition>");
- }
-
- public int
- getMajor()
- {
- return major;
- }
-
- public int
- getMinor()
- {
- return minor;
- }
-
- public long
- getBlocks()
- {
- return blocks;
- }
-
- public long
- getStartSect()
- {
- return start_sect;
- }
-
- public long
- getNumSects()
- {
- return nr_sects;
- }
-
- public String
- getName()
- {
- return name;
- }
-
- public boolean
- getIsXeno()
- {
- return xeno;
- }
-
-}
+++ /dev/null
-/*
- * PartitionManager.java
- * 03.03.26 aho creation
- */
-
-package uk.ac.cam.cl.xeno.xenctl;
-
-import java.io.*;
-import java.util.Vector;
-import java.util.Enumeration;
-
-public class
-PartitionManager
-{
- Vector partition_map;
-
- static String proc_template =
- "major minor #blocks start_sect nr_sects name";
-
- /*
- * Initialize partition manager with source file.
- * Normally we read from /proc/partitions, but we can
- * specify an alternative file for debugging
- */
- PartitionManager (String filename)
- {
- String str;
- BufferedReader in;
-
- partition_map = new Vector(100,10);
-
- try
- {
- in = new BufferedReader(new FileReader(filename));
-
- str = in.readLine(); /* skip headings */
- if (str.length() < proc_template.length() ||
- !str.substring(0, proc_template.length()).equals(proc_template))
- {
- System.err.println ("Error: Incorrect /proc/partitions.");
- System.err.println (" Is this Xeno?");
- System.exit (1);
- }
-
- str = in.readLine(); /* skip blank line */
-
- str = in.readLine();
- while (str != null)
- {
- Partition partition = new Partition();
-
- partition.major = Integer.parseInt(str.substring(0,5).trim());
- partition.minor = Integer.parseInt(str.substring(5,10).trim());
- partition.blocks = Integer.parseInt(str.substring(10,21).trim());
- partition.start_sect = Integer.parseInt(str.substring(21,32).trim());
- partition.nr_sects = Integer.parseInt(str.substring(32,43).trim());
- partition.name = str.substring(43).trim();
- partition.xeno = false;
-
- partition_map.add(partition);
- str = in.readLine();
- }
- }
- catch (IOException io)
- {
- System.err.println ("PartitionManager: error reading partition file ["
- + filename + "]");
- System.err.println (io);
- }
- }
-
- Partition
- get_partition (String name)
- {
- Partition partition = null;
- for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;)
- {
- partition = (Partition) e.nextElement();
- if (partition.name.equals(name))
- {
- return partition;
- }
- }
- return null;
- }
-
- Partition
- get_partition (int index)
- {
- return (Partition) partition_map.get(index);
- }
-
- void
- add_xeno_partition (Partition p)
- {
- for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;)
- {
- Partition partition = (Partition) e.nextElement();
- if (partition.identical(p))
- {
- partition.xeno = true;
- }
- }
- }
-
- /*
- * dump the xeno partition list as xml
- */
- void
- dump_xml (PrintWriter out)
- {
- int loop;
-
- out.println("<partitions>");
- for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;)
- {
- Partition partition = (Partition) e.nextElement();
- if (partition.xeno == true)
- {
- partition.dump_xml(out);
- }
- }
-
- out.println("</partitions>");
-
- return;
- }
-
- /*
- * dump the partition map as a string
- * mark: mark the current xeno partitions in the partition map
- */
- String
- dump (boolean mark)
- {
- int loop, idx;
- StringBuffer sb = new StringBuffer();
- Partition partition;
-
- for (idx = 0; idx < partition_map.size(); idx++)
- {
- partition = (Partition) partition_map.get(idx);
-
- if (idx == 0)
- {
- sb.append(" idx " + partition.dump(true) + "\n");
- }
- if (partition.xeno)
- {
- sb.append("[ ");
- }
- else
- {
- sb.append(" ");
- }
- sb.append(Library.format(idx,2,0) + " " + partition.dump(false));
- if (partition.xeno)
- {
- sb.append("]\n");
- }
- else
- {
- sb.append("\n");
- }
- }
-
- return sb.toString();
- }
-
- /**
- * get the number of partitions
- */
-
- int
- getPartitionCount ()
- {
- return partition_map.size();
- }
-
- /**
- * get the details about a particular partition
- *
- */
- Partition
- getPartition (int index)
- {
- Partition partition = (Partition) partition_map.get(index);
- return partition;
- }
-
-}
+++ /dev/null
-/*
- * XML.java
- * 03.03.26 aho creation
- */
-
-package uk.ac.cam.cl.xeno.xenctl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.FileWriter;
-import java.io.BufferedWriter;
-import java.io.FileNotFoundException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-public class
-XML
-{
- static Document document = null;
-
- /*
- * dump partition manager and virtual disk manager state to filename
- */
-
- static void
- dump_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
- {
- PrintWriter out;
-
- try
- {
- out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
- }
- catch (IOException e)
- {
- System.err.println ("XML.dump_state error [" + filename + "]");
- System.err.println (e);
- return;
- }
-
- out.println("<?xml version=\"1.0\"?>");
- out.println("<vdmanager>");
- pm.dump_xml(out);
- vdm.dump_xml(out);
- out.println("</vdmanager>");
-
- out.close();
- return;
- }
-
- /*
- * load partition manager and virtual disk manager state from filename
- */
- static void
- load_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
- {
- if (document == null)
- {
- load_file (filename);
- }
-
- XMLHelper.parse(pm, vdm, document);
- }
-
- /*
- * load XML from disk
- */
- static void
- load_file (String filename)
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- // factory.setNamespaceAware(true);
- // factory.setValidating(true);
-
- try
- {
- File file = new File(filename);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- document = builder.parse(file);
- }
- catch (SAXParseException spe) /* error generated by parser */
- {
- System.err.println ("xml parser exception on line " +
- spe.getLineNumber() +
- " for uri " + spe.getSystemId());
- System.err.println (spe.getMessage());
-
- Exception x = spe;
- if (spe.getException() != null)
- x = spe.getException();
- x.printStackTrace();
- System.exit(1);
- }
- catch (SAXException sxe)
- {
- Exception e = sxe;
- if (sxe.getException() != null)
- e = sxe.getException();
- e.printStackTrace();
- System.exit(1);
- }
- catch (ParserConfigurationException pce)
- {
- pce.printStackTrace();
- }
- catch (FileNotFoundException fnfe)
- {
- System.err.println ("warning: state file not found [" +
- filename + "]");
- }
- catch (IOException ioe)
- {
- ioe.printStackTrace();
- }
- return;
- }
-}
+++ /dev/null
-/*
- * XMLHelper.java
- * 03.03.27 aho creation
- */
-
-package uk.ac.cam.cl.xeno.xenctl;
-
-import java.util.Date;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class
-XMLHelper
-{
- static void
- dump_document (Document document)
- {
- dump_element(document.getDocumentElement(), 0);
- }
-
- static void
- dump_element (Element element, int indent)
- {
- NodeList nl = element.getChildNodes();
-
- System.out.println ("<" + element.getTagName() + ">");
- dump_nodelist(nl, indent + 1);
- System.out.println("</" + element.getTagName() + ">");
- }
-
- static void
- dump_nodelist (NodeList nl, int indent)
- {
- for (int loop = 0; loop < nl.getLength(); loop++)
- {
- Node node = nl.item(loop);
- switch (node.getNodeType())
- {
- case Node.ELEMENT_NODE :
- {
- dump_element((Element)node, indent);
- break;
- }
- case Node.TEXT_NODE :
- {
- System.out.println("TEXT: " + node.getNodeValue());
- break;
- }
- default :
- {
- System.out.println("NODE: " + node.getNodeType());
- }
- }
- }
- }
-
- static Node
- get_subnode (String name, Node node)
- {
- if (node.getNodeType() != Node.ELEMENT_NODE)
- {
- System.err.println("Error: Search node not of element type");
- return null;
- }
-
- if (!node.hasChildNodes()) return null;
-
- NodeList list = node.getChildNodes();
- for (int i=0; i < list.getLength(); i++)
- {
- Node subnode = list.item(i);
- if (subnode.getNodeType() == Node.ELEMENT_NODE)
- {
- if (subnode.getNodeName() == name) return subnode;
- }
- }
- return null;
- }
-
- static String
- get_text (Node node)
- {
- StringBuffer result = new StringBuffer();
- if (node==null || !node.hasChildNodes()) return "";
-
- NodeList list = node.getChildNodes();
- for (int i=0; i < list.getLength(); i++)
- {
- Node subnode = list.item(i);
- if (subnode.getNodeType() == Node.TEXT_NODE)
- {
- result.append(subnode.getNodeValue());
- }
- }
- return result.toString();
- }
-
- static void
- parse (PartitionManager pm, VirtualDiskManager vdm, Document document)
- {
- if (document == null) return;
-
- /* parse partitions */
- parse_partitions(pm, document.getElementsByTagName("partition"));
-
- /* parse virtual disks */
- NodeList list = document.getElementsByTagName("virtual_disk");
- for (int i = 0; i < list.getLength(); i++)
- {
- Node subnode = list.item(i);
- String parent = subnode.getParentNode().getNodeName();
- VirtualDisk vd = parse_virtual_disk(subnode);
-
- if (parent.equals("free"))
- {
- vdm.add_free(vd);
- }
- else if (parent.equals("virtual_disks"))
- {
- vdm.add_virtual_disk(vd);
- }
- else
- {
- System.out.println ("XML parse error: unknown parent for virtual_disk "
- + "[" + parent + "]");
- }
- }
-
- /* parse virtual block devices */
- parse_virtual_block_devices(vdm, document.getElementsByTagName("virtual_block_device"));
-
- return;
- }
-
- static VirtualDisk
- parse_virtual_disk(Node node)
- {
- VirtualDisk vd;
- Date date = new Date();
- NodeList list;
-
- date.setTime(Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("expiry", node))));
- vd = new VirtualDisk(XMLHelper.get_text(XMLHelper.get_subnode("name", node)),
- date,
- XMLHelper.get_text(XMLHelper.get_subnode("key", node)));
-
- list = XMLHelper.get_subnode("extents", node).getChildNodes();
- for (int i = 0; i < list.getLength(); i++)
- {
- Node enode = list.item(i);
-
- if (enode.getNodeType() == Node.ELEMENT_NODE &&
- enode.getNodeName().equals("extent"))
- {
- Extent extent = new Extent();
-
- extent.disk = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("disk", enode)));
- extent.size = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("size", enode)));
- extent.offset = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("offset", enode)));
- vd.add_extent(extent);
- }
- }
-
- return vd;
- }
-
- static void
- parse_partitions (PartitionManager pm, NodeList nl)
- {
- Partition partition;
-
- for (int loop = 0; loop < nl.getLength(); loop++)
- {
- Node node = nl.item(loop);
-
- partition = new Partition();
- partition.major = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("major", node)));
- partition.minor = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("minor", node)));
- partition.blocks = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("blocks", node)));
- partition.start_sect = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("start_sect", node)));
- partition.nr_sects = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("nr_sects", node)));
- partition.name = XMLHelper.get_text(XMLHelper.get_subnode("name", node));
-
- pm.add_xeno_partition(partition);
- }
- }
-
- static void
- parse_virtual_block_devices (VirtualDiskManager vdm, NodeList nl)
- {
- VirtualBlockDevice vbd;
-
- for (int loop = 0; loop < nl.getLength(); loop++)
- {
- Node node = nl.item(loop);
-
- vdm.create_virtual_block_device(XMLHelper.get_text(XMLHelper.get_subnode("key", node)),
- Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("domain", node))),
- Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("vbdnum", node))),
- XMLHelper.get_text(XMLHelper.get_subnode("mode", node)));
- }
- }
-}